package day7;

import java.util.Scanner;

/**
 * 猜数字小游戏
 * 训练目标：while（true）自选死循环
 */

public class Guessing {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = (int)(Math.random()*1000+1);
        while (true){
            System.out.println("请输入");
            int guess = sc.nextInt();
            if (guess>num){
                System.out.println("猜大了，往小了再猜");
            }else if (guess<num){
                System.out.println("猜小了，往大了再猜");
            }else {
                System.out.println("恭喜你，猜对了，是："+num);
                break;
            }
        }
    }
}
